/**
 * app.js为服务程序的主入口
 */

//1、引入http
const http = require('http')
//2、声明参数
let ip = '127.0.0.1'
let port = 8000
//3、创建服务对象
let server = http.createServer(function(request, response){
    //3-1、设置允许跨域访问
    response.setHeader('Access-Control-Allow-Origin', '*')
    //3-2解析request对象
    let url =request.url
    console.log(url);
    //3-3、设置全局的响应头
    response.setHeader('Content-type', 'text/plain;charset=utf-8')
    //3-4、响应信息
    response.write('hello this is node serverl')
    //3-5、终止响应,此函数后面不能再写其它代码，否则服务端报错
    response.end()
})
//4、启动服务，监听请求
server.listen(port, ip, () => {
    console.log(`Server is running on http://${ip}:${port}`);
    
})

// url= /login?username=admin&passworld=123456
